<?php
require_once('ly_check.php');
@header('Content-type: text/html;charset=UTF-8');
?>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>上报数据管理</title>
    <link rel="stylesheet" href="../images/css.css" type="text/css"/>
    <style>
        .btn
        {
            BORDER-RIGHT: #000000 1px solid;
            BORDER-TOP: 1px solid;
            FONT-SIZE: 9pt;
            BORDER-LEFT: #000000 1px solid;
            WIDTH: 40pt;
            BORDER-BOTTOM: #000000 1px solid;
            HEIGHT: 16pt;
            BACKGROUND-COLOR: #e7e7e7;
            cursor:hand;
        }
    </style>
</head>
<body>
<?php
$sql = "SELECT * from uploadlog where 1=1 ";
$userId = $_GET['userId'];
$uploaddate = $_GET['uploaddate'];
if ($_SESSION["flag"] == 2) {
    $sql = $sql . " and userId = '" . $_SESSION["userId"] . "'";
}
if (str_replace(' ','',$userId) != ""){
    $_SESSION['servicecode'] = str_replace(' ','',$userId);
    $sql = $sql . " and code = '" . $_SESSION["servicecode"] . "'";
}else{
    $_SESSION['servicecode'] = '';
}
if ($uploaddate != ""){
    $_SESSION['uploaddate'] = $uploaddate;
    $sql = $sql . " and DATE_FORMAT(upLoadDate,'%Y-%m-%d') = '" . $_SESSION["uploaddate"] . "'";
}else{
    $_SESSION['uploaddate'] = '';
}
$sql = $sql . " order by upLoadDate desc";
$rs = mysql_query($sql);
$recordcount = mysql_num_rows($rs);
$pagecount = ($recordcount - 1) / $pagesize + 1;
$pagecount = (int)$pagecount;
$pageno = $_GET["pageno"];
if ($pageno < 1) {
    $pageno = 1;
}
if ($pageno > $pagecount) {
    $pageno = $pagecount;
}
$startno = ($pageno - 1) * $pagesize;
$sql = "SELECT * from uploadlog where 1=1 ";
if ($_SESSION["flag"] == 2) {
    $sql = $sql . " and userId = '" . $_SESSION["userId"] . "'";
}
if (str_replace(' ','',$userId) != ""){
    $_SESSION['servicecode'] = str_replace(' ','',$userId);
    $sql = $sql . " and code = '" . $_SESSION["servicecode"] . "'";
}
if ($uploaddate != ""){
    $_SESSION['uploaddate'] = $uploaddate;
    $sql = $sql . " and DATE_FORMAT(upLoadDate,'%Y-%m-%d') = '" . $_SESSION["uploaddate"] . "'";
}
$sql = $sql . " order by upLoadDate desc limit $startno,$pagesize";
$rs = mysql_query($sql);
?>
<table width="100%" border="0" cellpadding="5" cellspacing="0" class="table">
    <tr>
        <td class="bg_tr">上报数据日志</td>
        <td class="bg_tr" style="width:80%;text-align:right;">
            <form action="" method="get">
                站点编码:<input type="text" name="userId" style="margin:0px 5px 0 5px;" value="<?php echo $_SESSION['servicecode'] ?>" />
                上报日期:<input type="date" name="uploaddate" style="margin:0px 5px 0 5px;" value="<?php
                if ($_SESSION['uploaddate']!=""){
                    echo $_SESSION['uploaddate'];
                }
                ?>" />
                <input type="submit" value="搜索" class="btn" />
            </form>
        </td>
    </tr>
</table>

<table width="100%" border="0" align="center" cellpadding="5" cellspacing="1" class="td_bgf">
    <thead>
    <tr>
        <th>序号</th>
        <th>企业编码</th>
        <th>企业名称</th>
        <th>站点编码</th>
        <th>站点名称</th>
        <th>站点类型</th>
        <th>上报日期</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    <?php
    $i = 1;
    while ($rows = mysql_fetch_assoc($rs)) {
        ?>
        <tr>
            <td class="td_bg" align="center"><?php echo $i ?></td>
            <td class="td_bg" align="center"><?php echo $rows["userId"] ?></td>
            <td class="td_bg" align="center"><?php echo $rows["userName"] ?></td>
            <td class="td_bg" align="center"><?php echo $rows["code"] ?></td>
            <td class="td_bg" align="center"><?php echo $rows["name"] ?></td>
            <td class="td_bg" align="center"><?php echo $rows["countyTypeName"] ?></td>
            <td class="td_bg" align="center"><?php echo $rows["upLoadDate"] ?></td>
            <td class="td_bg" align="center"><a href="detail.php?servicecode=<?php echo $rows["code"] ?>&uploaddate=<?php echo $rows["upLoadDate"] ?>"><font
                            color=black>查看明细</font></a></td>
        </tr>
        <?php
        $i++;
    }
    ?>
    </tbody>
    <tfoot>
    <tr>
        <td colspan="8" align="center" class="bg_tr">
            <?php
            echo "共" . $recordcount . "条记录   ";
            for ($i = 1; $i <= $pagecount; $i++) {
                ?>
                <a href="?pageno=<?php echo $i ?>&code=<?php echo $_SESSION['servicecode'] ?>&uploaddate=<?php echo $_SESSION['uploaddate'] ?>"><?php echo $i ?></a>
                <?php
            }
            ?>
            <?php
            if ($pageno == 1) {
                if ($pageno == $pagecount) {
                    ?>
                    首页 | 上页 | 下页  | 末页
                    <?php
                } else { ?>
                    首页 | 上页 | <a href="?pageno=<?php echo $pageno + 1 ?>&code=<?php echo $_SESSION['servicecode'] ?>&uploaddate=<?php echo $_SESSION['uploaddate'] ?>">下页</a> | <a
                            href="?pageno=<?php echo $pagecount ?>">末页</a>
                <?php }
            } else if ($pageno == $pagecount) {
                ?>
                <a href="?pageno=1&code=<?php echo $_SESSION['servicecode'] ?>&uploaddate=<?php echo $_SESSION['uploaddate'] ?>">首页</a> | <a href="?pageno=<?php echo $pageno - 1 ?>&code=<?php echo $_SESSION['servicecode'] ?>&uploaddate=<?php echo $_SESSION['uploaddate'] ?>">上页</a> | 下页 | 末页
                <?php
            } else {
                ?>
                <a href="?pageno=1&code=<?php echo $_SESSION['servicecode'] ?>&uploaddate=<?php echo $_SESSION['uploaddate'] ?>">首页</a> | <a href="?pageno=<?php echo $pageno - 1 ?>&code=<?php echo $_SESSION['servicecode'] ?>&uploaddate=<?php echo $_SESSION['uploaddate'] ?>">上页</a> | <a
                        href="?pageno=<?php echo $pageno + 1 ?>&code=<?php echo $_SESSION['servicecode'] ?>&uploaddate=<?php echo $_SESSION['uploaddate'] ?>">下页</a> | <a
                        href="?pageno=<?php echo $pagecount ?>&code=<?php echo $_SESSION['servicecode'] ?>&uploaddate=<?php echo $_SESSION['uploaddate'] ?>">末页</a>
                <?php
            }
            ?></td>
    </tr>
    </tfoot>
</table>
</body>
</html>
